package ar.edu.caece.compiler.grammar.attributes.tree;

public class NodeCadena extends NodeExpr {
	private String valor;
	private String idVariable;

	public NodeCadena(String valor, String idVariable) {
		super();
		this.valor = valor;
		this.idVariable = idVariable;
	}
	
	public NodeCadena(String valor) {
		super();
		this.valor = valor;
	}

	public String getValor() {
		return valor;
	}
	
	public int getLongitud() {
		return valor.length();
	}

	public void setValor(String valor) {
		this.valor = valor;
	}
	
	public String toString() {
		return "[Nodo cadena: -> " + valor +" ]";
	}

	@Override
	public String generateCode() {
		return "cadena"+idVariable;
	}

	public String generateDeclaration() {
		return "cadena"+idVariable +" dw \""+valor+"\";"+valor.length();
	}
	
	public void setIdVariable(String idVariable) {
		this.idVariable = idVariable;
	}

	public String getIdVariable() {
		return idVariable;
	}
	
	public int getLength() {
		return valor.length();
	}

	public boolean isCadena() {
		return true;
	}
	
	public String getWriteRoutineName() {
		return "writeSTR";
	}
}
